package com.justplay.mobilelocation.UI;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.justplay.mobilelocation.R;
import com.justplay.mobilelocation.util.SharePreferencesUtil;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.justplay.mobilelocation.util.Config.kefuMobile;
import static com.justplay.mobilelocation.util.Config.kefuQq;


public class ContactUsActivity extends AppCompatActivity {

    @Bind(R.id.ll_phone)
    LinearLayout ll_phone;
    @Bind(R.id.ll_qq)
    LinearLayout ll_qq;
    @Bind(R.id.tv_phone)
    TextView tv_phone;
    @Bind(R.id.tv_qq)
    TextView tv_qq;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_contact_us);
        ButterKnife.bind(this);
        String mobile = SharePreferencesUtil.getString(kefuMobile, "", ContactUsActivity.this);
        String qq = SharePreferencesUtil.getString(kefuQq, "", ContactUsActivity.this);

        tv_phone.setText(mobile);
        tv_qq.setText(qq);
//        getCustomerMsg();
    }



    public static void startQQ(Context mContext, int type, String qqnum) {
        String url = null;
        switch (type) {
            case 1:
                // 直接进入QQ聊天(对QQ号)
                url = "mqqwpa://im/chat?chat_type=wpa&uin=" + qqnum;
                break;
            case 2:
                // 打开个人介绍界面（对QQ号）
                url = "mqqapi://card/show_pslcard?src_type=internal&version=1&uin=" + qqnum
                        + "&card_type=person&source=qrcode";
                break;
            case 3:
                // 打开QQ群介绍界面(对QQ群号)
                url = "mqqapi://card/show_pslcard?src_type=internal&version=1&uin=" + qqnum
                        + "&card_type=group&source=qrcode";
                break;

            default:
                break;
        }
        mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
    }

    @OnClick({R.id.ll_phone, R.id.ll_qq})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ll_phone:
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_CALL);
                intent.setData(Uri.parse("tel:" + tv_phone.getText().toString()));
                startActivity(intent);
                break;
            case R.id.ll_qq:
                startQQ(this, 1, tv_qq.getText().toString());
                break;
        }
    }
}
